package com.it.a08test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Random;

public class Test2 {
    public static void main(String[] args) {
            /*
        班级里有N个学生
        要求：
        70%的概率随机到男生
        30%的概率随机到女生
     */

        //1.创建一个集合用来表示概率
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,1,1,1,1,1,1);
        Collections.addAll(list,0,0,0);
        //打乱集合
        Collections.shuffle(list);
        //进行随机
        Random r = new Random();
        int index = r.nextInt(list.size());
        int number = list.get(index);
        System.out.println(number);

        //创建男生和女生的集合
        ArrayList<String> boylist = new ArrayList<>();
        Collections.addAll(boylist,"范闲","张三","李四","王五","王二","朱元璋","王阳明");
        ArrayList<String> girllist = new ArrayList<>();
        Collections.addAll(girllist,"七月","美丽","三妹","可可");
        if(number == 1){
            int boyindex = r.nextInt(boylist.size());
            String boyname = boylist.get(boyindex);
            System.out.println(boyname);
        }else{
            int girlindex = r.nextInt(girllist.size());
            String girlname = girllist.get(girlindex);
            System.out.println(girlname);
        }
    }
}
